package nju.software.tagmanager.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import nju.software.tagmanager.common.result.Result;
import nju.software.tagmanager.service.CategoryService;
import nju.software.tagmanager.service.ItemService;
import nju.software.tagmanager.service.TagService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: raychou
 * @date: 2024-01-17 16:49
 * @description:
 */
@Api(tags = "数据接口")
@RestController
@RequestMapping("/statistics")
@Slf4j
public class StatisticsController {

    @Resource
    private TagService tagService;

    @Resource
    private CategoryService categoryService;

    @Resource
    private ItemService itemService;

    @GetMapping("/categories")
    public Result<Integer> categories() {
        return Result.success(Math.toIntExact(categoryService.count()));
    }
    @GetMapping("/tags")
    public Result<Integer> tags() {
        return Result.success(Math.toIntExact(tagService.count()));
    }

    @GetMapping("/items")
    public Result<Integer> items() {
        return Result.success(Math.toIntExact(itemService.count()));
    }


}
